<template>
	<div>
    <Form>
        <FormItem label="积分名称" required>
					<Input style="width:400px" v-model="dataBus.vpoName" placeholder="请输入积分名称"></Input>
				</FormItem>
        <FormItem label="奖惩类型" required>
					<RadioGroup v-model="dataBus.vpoType">
            <Radio :label="1"><span>加分项</span></Radio>
            <Radio :label="0"><span>扣分项</span></Radio>
          </RadioGroup>
				</FormItem>
        <FormItem label="最小分值" required>
					<InputNumber style="width:100px" v-model="dataBus.minPoints" placeholder="请输入积分最小分值"></InputNumber>
				</FormItem>
        <FormItem label="最大分值" required>
					<InputNumber style="width:100px" v-model="dataBus.maxPoints" placeholder="请输入积分最大分值"></InputNumber>
				</FormItem>
        <FormItem label="默认打分值">
					<InputNumber style="width:100px" v-model="dataBus.defaultPoints" placeholder="请输入默认打分值"></InputNumber>
				</FormItem>
        <FormItem label="积分货币价值(元)">
					<InputNumber style="width:100px" v-model="dataBus.pointsAmt" placeholder="请输入1积分对应的货币价值"></InputNumber>
				</FormItem>
        <FormItem label="积分描述">
					<Input style="width:400px" v-model="dataBus.vpoNotes" placeholder="请输入积分描述"></Input>
				</FormItem>
        <FormItem label="排序" required>
					<InputNumber style="width:100px" v-model="dataBus.sortIndex" placeholder="请输入积分项排序"></InputNumber>
				</FormItem>
        <FormItem label="可用状态" required>
					<RadioGroup v-model="dataBus.vpoStatus">
            <Radio :label="1"><span>可用</span></Radio>
            <Radio :label="0"><span>不可用</span></Radio>
          </RadioGroup>
				</FormItem>
      </Form>
    <Button type="primary" @click="Submit">提交</Button>
  </div>  
</template>

<script scope>
export default {
  props: {
    dataBus: Object,
    callbank: Function
  },
  data () {
    return {
      dataForm: {}
    }
  },
  methods: {
    Submit(){
      this.dataForm.vpoId = this.dataBus.vpoId
      this.dataForm.vpoName = this.dataBus.vpoName
      this.dataForm.vpoType = this.dataBus.vpoType
      this.dataForm.minPoints = this.dataBus.minPoints
      this.dataForm.maxPoints = this.dataBus.maxPoints
      this.dataForm.defaultPoints = this.dataBus.defaultPoints
      this.dataForm.pointsAmt = this.dataBus.pointsAmt
      this.dataForm.vpoNotes = this.dataBus.vpoNotes
      this.dataForm.sortIndex = this.dataBus.sortIndex
      this.dataForm.vpoStatus = this.dataBus.vpoStatus

      new this.$rest({
        gateway: 'agrobiz',
        service: "agrobiz-uc",
        url: "/v1.0/villager/points/option",
        data: {
          pojo: this.dataForm
        },
        action: (res) => {
          if (res.data.code === 20000) {
            this.$Message.success({
              content: '编辑成功',
              duration: 1,
              onClose: ()=> {
                this.callbank()
              }
            })
          } else {
            this.$Notice.warning({
              desc: `失败原因：${res.data.msg}`,
            });
          }
        },
      }).put()
    },
  }
}
</script>